import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-stars',
  templateUrl: './stars.component.html',
  styleUrls: ['./stars.component.css']
})
export class StarsComponent implements OnInit {

  @Input()
  private rating: number = 0;

  // 初始化一定要给，如果这里不给，那么在用之前一定要现初始化，否则会报错，找不到push方法或者属性
  private stars: Array<boolean> = [];
  constructor() { }

  ngOnInit() {
    for( let i= 1; i<=5; i++) {
      this.stars.push(i > this.rating);
    }
  }

}
